

package com.haoxi.gateway.smgpmsg;

import com.haoxi.gateway.util.TypeConvert;



public class SMGPExitMessage extends SMGPMessage {

    public SMGPExitMessage() {
        int len = 12;
        buf = new byte[len];
        TypeConvert.int2byte(len, buf, 0);
        TypeConvert.int2byte(SMGPCommon.SMGP_EXIT, buf, 4);
    }

    public SMGPExitMessage(byte buf[]) throws IllegalArgumentException {
        super.buf = new byte[4];
        if (buf.length != 4) {
            throw new IllegalArgumentException(
                    "The message that is sent by SMC is wrong");
        } else {
            System.arraycopy(buf, 0, super.buf, 0, 4);
            sequence_Id = TypeConvert.byte2int(super.buf, 0);
            return;
        }
    }

    public String toString() {
        StringBuffer strBuf = new StringBuffer(100);
        strBuf.append("SMGPExitMessage: ");
        strBuf.append("PacketLength=").append(buf.length);
        strBuf.append(",RequestID=").append("0x").append(Integer.toHexString(getRequestId()));
        strBuf.append(",Sequence_Id=").append(getSequenceId());
        return strBuf.toString();
    }

    public int getRequestId() {
        return SMGPCommon.SMGP_EXIT;
    }
}
